<?php

include_once 'autoload.php';

class FormLogin extends Zend_Form {

    public function init() {
        $pwdValide = new Zend_Validate_Regex('((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20})');
        $pwdValide->setMessage("6 a 20 caracteres, au moins 1 chiffre, au moins une majuscule");

        $this->setName('Login');

        $userName = new Zend_Form_Element_Text('userName');

        $userName->setLabel('Nom: ')
                ->setRequired();

        $password = new Zend_Form_Element_Password('password');

        $password->setLabel('Mot de passe:')
                ->setRequired()
                ->addValidator($pwdValide);

        $login = new Zend_Form_Element_Submit('login');

        $login->setLabel('Envoyer');

        $this->addElements(array($userName, $password, $login))
                ->setMethod('post')
                ->setAction('formAuth02.php');
    }

}



$view = new Zend_View(); //autoload

$form = new FormLogin(); //autoload

if (!$_POST) {

// rendu du formulaire vierge 
echo 'mauvais';
    echo $form->render($view);
} else

if (!$form->isValid($_POST)) {

// rendu du formulaire rempli et messages d'erreurs 

    echo $form->render($view);
} else {
Zend_Debug::dump($form->getValues());
echo 'parfait';
}
?>